﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bmz.Laboratory.Workflow.Repository
{
    public interface IRepository<TDataBase> where TDataBase : DbContext, new()
    {
        IList<TTable> SqlQuery<TTable>(string sql, params object[] parameters);

        int ExecuteSqlCommand(string sql, params object[] parameters);

        TTable Add<TTable>(TTable entity) where TTable : class;

        IEnumerable<TTable> AddRange<TTable>(IEnumerable<TTable> listEntity) where TTable : class;

        TTable Update<TTable>(TTable entity) where TTable : class;

        TTable Delete<TTable>(TTable entity) where TTable : class;

        IEnumerable<TTable> DeleteRange<TTable>(IEnumerable<TTable> listEntity) where TTable : class;

        TTable GetEntityByKey<TTable>(int id) where TTable : class;

        IQueryable<TTable> GetEntityList<TTable>(Func<TTable, bool> filter) where TTable : class;

        TDataBase DbContext { get; }

        int Commit(bool isDispose = true);

        void Dispose();
    }
}
